package com.fr.cell.core;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.AbstractBorder;

public class ModLineBorder extends AbstractBorder
{
  public static final int TOP = 1;
  public static final int LEFT = 2;
  public static final int BOTTOM = 4;
  public static final int RIGHT = 8;
  private int modifiers;
  private int thickness;
  private Color lineColor;

  public ModLineBorder(int paramInt)
  {
    this(paramInt, GUICoreUtils.getTitleLineBorderColor(), 1);
  }

  public ModLineBorder(int paramInt, Color paramColor)
  {
    this(paramInt, paramColor, 1);
  }

  public ModLineBorder(int paramInt1, Color paramColor, int paramInt2)
  {
    this.modifiers = 0;
    this.modifiers = paramInt1;
    this.lineColor = paramColor;
    this.thickness = paramInt2;
  }

  public void paintBorder(Component paramComponent, Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    Color localColor = paramGraphics.getColor();
    paramGraphics.setColor(this.lineColor);
    for (int i = 0; i < this.thickness; ++i)
    {
      if ((this.modifiers & 0x1) != 0)
        paramGraphics.drawLine(paramInt1 + i, paramInt2 + i, paramInt1 + paramInt3 - i - 1, paramInt2 + i);
      if ((this.modifiers & 0x2) != 0)
        paramGraphics.drawLine(paramInt1 + i, paramInt2 + i, paramInt1 + i, paramInt2 + paramInt4 - i - 1);
      if ((this.modifiers & 0x4) != 0)
        paramGraphics.drawLine(paramInt1 + i, paramInt2 + paramInt4 - i - 1, paramInt1 + paramInt3 - i - 1, paramInt2 + paramInt4 - i - 1);
      if ((this.modifiers & 0x8) != 0)
        paramGraphics.drawLine(paramInt1 + paramInt3 - i - 1, paramInt2 + i, paramInt1 + paramInt3 - i - 1, paramInt4 - i - i - 1);
    }
    paramGraphics.setColor(localColor);
  }

  public Insets getBorderInsets(Component paramComponent)
  {
    return getBorderInsets(paramComponent, new Insets(this.thickness, this.thickness, this.thickness, this.thickness));
  }

  public Insets getBorderInsets(Component paramComponent, Insets paramInsets)
  {
    paramInsets.left = (paramInsets.top = paramInsets.right = paramInsets.bottom = this.thickness);
    if (((this.modifiers & 0x1) != 0) && ((this.modifiers & 0x4) == 0))
      paramInsets.bottom = 0;
    if (((this.modifiers & 0x2) != 0) && ((this.modifiers & 0x8) == 0))
      paramInsets.right = 0;
    if (((this.modifiers & 0x4) != 0) && ((this.modifiers & 0x1) == 0))
      paramInsets.top = 0;
    if (((this.modifiers & 0x8) != 0) && ((this.modifiers & 0x2) == 0))
      paramInsets.left = 0;
    return paramInsets;
  }

  public int getModifiers()
  {
    return this.modifiers;
  }

  public void setModifiers(int paramInt)
  {
    this.modifiers = paramInt;
  }

  public Color getLineColor()
  {
    return this.lineColor;
  }

  public int getThickness()
  {
    return this.thickness;
  }
}